package com.by.sbdemoby.config;

import com.by.sbdemoby.interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @auth wzy
 * @date 2023/12/9 10:27
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        String[] pathPatterns = {"/index"};    //拦截路径规则
//        String[] excludePathPatterns = {"/login","/regist","/statics/**"};  //排除路径规则

        registry.addInterceptor(new MyInterceptor())     //注册拦截器
                .addPathPatterns(pathPatterns);  //添加路径规则
//                .excludePathPatterns(excludePathPatterns);      //添加排除路径规则
    }
}
